package softOffer;

import java.util.Arrays;

public class Question3 {
	public int minNumberInRotateArray(int[] array) {
		if (array.length == 0) {
			return 0;
		}
		int count = array.length / 2;
		int[] array1 = new int[count];
		for (int i = 0; i < count; i++) {
			array1[i] = array[i];
		}
		int temp = 1;
		for (int i = 0; i < array.length; i++) {
			if (i <= array1.length) {
				if (array.length % 2 == 0) {
					array[i] = array[count - 1 + i];
				} else {
					array[i] = array[count + i];
				}

			} else {
				array[i] = array1[i - count - temp];
			}
		}

		Arrays.sort(array);
		System.out.println(array[0]);
		return 0;
	}

	public static void main(String[] args) {
		Question3 question3 = new Question3();
		int[] a = { 6501, 6828, 6963, 7036, 7422, 7674, 8146, 8468, 8704, 
				8717, 9170, 9359, 9719, 9895, 9896, 9913,
				9962, 154, 293, 334, 492, 1323, 1479, 1539, 1727, 1870, 1943, 2383, 
				2392, 2996, 3282, 3812, 3903, 4465,
				4605, 4665, 4772, 4828, 5142, 5437, 5448, 5668, 5706, 5725, 6300, 6335 };
		question3.minNumberInRotateArray(a);
	}
}
